package com.haha.constant;

/**
 * @author zouwz5
 * @date 2025/10/2 20:39
 * 基础枚举
 */
public enum BaseCode {

    SUCESS(0, "ok"),
    SYSTEM_ERROR(-1, "系统异常，请稍后重试"),
    PARAMETER_ERROR(10054,"参数验证异常"),

    // 数据库记录状态
    IS_DELETED(0,"已删除"),
    NOT_DELETED(1,"未删除")
    ;

    private final Integer code;

    private String msg = "";

    BaseCode(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return this.code;
    }

    public String getMsg() {
        return this.msg == null ? "" : this.msg;
    }

    public static String getMsg(Integer code) {
        for (BaseCode re : BaseCode.values()) {
            if (re.code.intValue() == code.intValue()) {
                return re.msg;
            }
        }
        return "";
    }

    public static BaseCode getRc(Integer code) {
        for (BaseCode re : BaseCode.values()) {
            if (re.code.intValue() == code.intValue()) {
                return re;
            }
        }
        return null;
    }
}
